package com.gitee.wsl.service.mq

/*import com.gitee.wsl.service.Server
import kotlinx.io.IOException
import java.io.IOException
import java.util.Collections
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.DelayQueue
import java.util.concurrent.Delayed
import java.util.concurrent.TimeUnit
import kotlin.random.Random

open class MQServer(val serverListener: MqServiceListener = MqServiceListener(false)) {
    //服务端监听器
    //private var serverListener: MqServiceListener? = null

    //服务端
    private var server: Server? = null

    //服务端配置处理
    //private var serverConfigHandler: ServerConfigHandler? = null


    *//**
     * 服务端配置
     *//*
    *//*fun config(configHandler: ServerConfigHandler?): MqServer? {
        serverConfigHandler = configHandler
        return this
    }*//*

    fun watcher(watcher: MqWatcher<Session>): MQServer {
        serverListener.watcher(watcher)
        return this
    }

    *//**
     * 配置访问账号
     *
     * @param accessKey       访问者身份
     * @param accessSecretKey 访问者密钥
     *//*
    fun addAccess(accessKey: String, accessSecretKey: String): MQServer {
        serverListener.addAccess(accessKey, accessSecretKey)
        return this
    }

    *//**
     * 配置访问账号
     *
     * @param accessMap 访问账号集合
     *//*
    fun addAccessAll(accessMap: Map<String, String>): MQServer {
        serverListener.addAccessAll(accessMap)
        return this
    }

    *//**
     * 启动
     *//*
    @Throws(Exception::class)
    fun start(port: Int): MQServer {

        //创建 SocketD 服务并配置（使用 tpc 通讯）
        *//*server = SocketD.createServer("sd:tcp")
        if (serverConfigHandler != null) {
            server.config(serverConfigHandler)
        }
        server.config { c -> c.port(port) }.listen(serverListener)
        serverListener!!.start(error.NonExistentClass {
            //启动
            server!!.start()
        })*//*
        return this
    }

    *//**
     * 停止
     *//*
    fun stop() {
        serverListener.stop {
            //停止
            server!!.stop()
        }
    }

}

*//**
 * 消息服务监听器
 *
 * @author noear
 * @since 1.0
 *//*
class MqServiceListener(private val brokerMode: Boolean,
                         //观察者
                        private var watcher: MqWatcher<Session> = MqWatcherDefault()
)  {
    //服务端访问账号
    private val serverAccessMap: MutableMap<String, String> = HashMap()


    //订阅关系表(topicConsumer=>MqTopicConsumerQueue)
    private val subscribeMap: MutableMap<String, MutableSet<String>> = HashMap()

    //主题消费队列表(topicConsumer=>MqTopicConsumerQueue)
    private val topicConsumerMap: MutableMap<String, MqTopicConsumerQueue<Session>> = HashMap()

    protected val callList= mutableMapOf<String,(Session, Message)->Unit>()

    init {
        //::初始化 Watcher 接口
       // watcher
       // watcher.init(this)

        //::初始化 BuilderListener(self) 的路由监听

        //接收订阅指令
        on(MqConstants.MQ_EVENT_SUBSCRIBE) { s, m ->
            val topic: String = m.meta(MqConstants.MQ_META_TOPIC)
            val consumer: String = m.meta(MqConstants.MQ_META_CONSUMER)

            //观察者::订阅时（适配时，可选择同步或异步。同步可靠性高，异步性能好）
            watcher.onSubscribe(topic, consumer, s)

            //观察后，再答复（以支持同步的原子性需求。同步或异步，由用户按需控制）
            if (m.isRequest() || m.isSubscribe()) {
                //发送“确认”，表示服务端收到了
                s.replyEnd(m, "")
            }

            //执行订阅
            subscribeDo(topic, consumer, s)
        }

        //接收取消订阅指令
        on(MqConstants.MQ_EVENT_UNSUBSCRIBE) { s, m ->
            val topic: String = m.meta(MqConstants.MQ_META_TOPIC)
            val consumer: String = m.meta(MqConstants.MQ_META_CONSUMER)

            //观察者::取消订阅时（适配时，可选择同步或异步。同步可靠性高，异步性能好）
            watcher.onUnSubscribe(topic, consumer, s)

            //观察后，再答复（以支持同步的原子性需求。同步或异步，由用户按需控制）
            if (m.isRequest() || m.isSubscribe()) {
                //发送“确认”，表示服务端收到了
                s.replyEnd(m, "")
            }

            //执行取消订阅
            unsubscribeDo(topic, consumer, s)
        }

        //接收发布指令
        on(MqConstants.MQ_EVENT_PUBLISH) { s, m ->
            //观察者::发布时（适配时，可选择同步或异步。同步可靠性高，异步性能好）
            watcher.onPublish(m)

            //观察后，再答复（以支持同步的原子性需求。同步或异步，由用户按需控制）
            if (m.isRequest() || m.isSubscribe()) { //此判断兼容 Qos0, Qos1
                //发送“确认”，表示服务端收到了
                s.replyEnd(m, "")
            }

            //执行交换
            exchangeDo(m)
        }

        //接收保存指令
        on(MqConstants.MQ_EVENT_SAVE) { _, _ -> save() }
    }

    fun on(topic: String,block:(Session, Message)->Unit){
        this.callList[topic] = block
    }

    fun watcher(watcher: MqWatcher<Session>): MqServiceListener {
        this.watcher = watcher
        //this.watcher.init(this)
        return this
    }

    *//**
     * 配置访问账号
     *
     * @param accessKey       访问者身份
     * @param accessSecretKey 访问者密钥
     *//*
    fun addAccess(accessKey: String, accessSecretKey: String): MqServiceListener {
        serverAccessMap[accessKey] = accessSecretKey
        return this
    }

    *//**
     * 配置访问账号
     *
     * @param accessMap 访问账号集合
     *//*
    fun addAccessAll(accessMap: Map<String, String>): MqServiceListener {
        serverAccessMap.putAll(accessMap)
        return this
    }

    *//**
     * 启动
     *//*
    @Throws(Exception::class)
    fun start(onStart: ()->Unit) {

        //观察者::服务启动之前
        watcher.onStartBefore()

        //启动
        onStart()

        //观察者::服务启动之后
        watcher.onStartAfter()
    }

    *//**
     * 保存
     *//*
    fun save() {
        //观察者::保存时
        watcher.onSave()
    }

    *//**
     * 停止
     *//*
    fun stop(onStop: ()->Unit) {
        //观察者::服务停止之前
        watcher.onStopBefore()

        //停止
        onStop()

        //观察者::服务停止之后
        watcher.onStopAfter()

        //关闭队列
        val queueList: List<MqTopicConsumerQueue<Session>> = ArrayList(topicConsumerMap.values)
        for (queue in queueList) {
            queue.close()
        }
    }

    *//**
     * 会话打开时
     *//*
    @Throws(IOException::class)
    fun onOpen(session: Session) {
        if (brokerMode) {
            return
        }
        if (serverAccessMap.isNotEmpty()) {
            //如果有 ak/sk 配置，则进行鉴权
            val accessKey: String = session.param(MqConstants.PARAM_ACCESS_KEY)
            val accessSecretKey: String = session.param(MqConstants.PARAM_ACCESS_SECRET_KEY)
            if (accessKey == null || accessSecretKey == null) {
                session.close()
                return
            }
            if (accessSecretKey != serverAccessMap[accessKey]) {
                session.close()
                return
            }
        }
        //log.info("Server channel opened, sessionId={}", session.sessionId())
    }

    *//**
     * 会话关闭时
     *//*
    fun onClose(session: Session) {
        if (brokerMode) {
            return
        }
        //log.info("Server channel closed, sessionId={}", session.sessionId())

        //遍历这个会话身上的消费者身份（有些可能不是）
        //避免遍历 Set 时，出现 add or remove 而异常
        val topicConsumerList= session.attrMap().keys
        for (topicConsumer in topicConsumerList) {
            val topicConsumerQueue = topicConsumerMap[topicConsumer]

            //如果找到对应的队列（如果没有，表示这个属性不是消费者）
            topicConsumerQueue?.removeSession(session)
        }
    }

    *//**
     * 会话出错时
     *//*
    fun onError(session: Session, error: Throwable) {
        *//*if (log.isWarnEnabled()) {
            if (error is SocketdAlarmException) {
                val alarmException: SocketdAlarmException = error as SocketdAlarmException
                log.warn(
                    "Server channel error, sessionId={}, from={}",
                    session.sessionId(),
                    alarmException.getFrom(),
                    error
                )
            } else {
                log.warn("Server channel error, sessionId={}", session.sessionId(), error)
            }
        }*//*
    }

    fun getSubscribeMap(): Map<String, MutableSet<String>> {
        return subscribeMap
    }

    fun getTopicConsumerMap(): Map<String, MqTopicConsumerQueue<Session>> {
        return topicConsumerMap
    }

    *//**
     * 执行订阅
     *//*
    @Synchronized
    fun subscribeDo(topic: String, consumer: String, session: Session) {
        val topicConsumer = topic + MqConstants.SEPARATOR_TOPIC_CONSUMER + consumer

        //::1.构建订阅关系

        //以身份进行订阅(topic=>[topicConsumer])
        var topicConsumerSet = subscribeMap[topic]
        if (topicConsumerSet == null) {
            topicConsumerSet = HashSet()
            subscribeMap[topic] = topicConsumerSet
        }
        topicConsumerSet.add(topicConsumer)

        //为身份建立队列(topicConsumer=>MqTopicConsumerQueue)
        var topicConsumerQueue = topicConsumerMap[topicConsumer]
        if (topicConsumerQueue == null) {
            topicConsumerQueue = MqTopicConsumerQueueDefault(watcher, topic, consumer)
            topicConsumerMap[topicConsumer] = topicConsumerQueue
        }

        //::2.标识会话身份（从持久层恢复时，会话可能为 null）
        if (session != null) {
            *//*log.info(
                "Server channel subscribe topic={}, consumer={}, sessionId={}",
                topic,
                consumer,
                session.sessionId()
            )*//*

            //会话添加身份（可以有多个不同的身份）
            session.attr(topicConsumer, "1")

            //加入主题消息队列
            topicConsumerQueue.addSession(session)
        }
    }

    *//**
     * 执行取消订阅
     *//*
    @Synchronized
    fun unsubscribeDo(topic: String, consumer: String, session: Session) {
        val topicConsumer = topic + MqConstants.SEPARATOR_TOPIC_CONSUMER + consumer

        //1.获取身份建立队列(topicConsumer=>MqTopicConsumerQueue)
        val topicConsumerQueue = topicConsumerMap[topicConsumer]

        //::2.移除会话身份（从持久层恢复时，会话可能为 null）
        if (session != null) {
            *//*log.info(
                "Server channel unsubscribe topic={}, consumer={}, sessionId={}",
                topic,
                consumer,
                session.sessionId()
            )*//*

            //会话移除身份（可以有多个不同的身份）
            session.attrMap().remove(topicConsumer)

            //退出主题消息队列
            topicConsumerQueue?.removeSession(session)
        }
    }

    *//**
     * 执行交换
     *//*
    fun exchangeDo(message: Message) {
        val tid: String = message.meta(MqConstants.MQ_META_TID)
        //可能是非法消息
        if (tid.isEmpty()) {
            //log.warn("The tid cannot be null, sid={}", message.sid())
            return
        }

        //复用解析
        val topic: String = message.meta(MqConstants.MQ_META_TOPIC)
        val qos = if ("0" == message.meta(MqConstants.MQ_META_QOS)) 0 else 1
        var scheduled: Long = 0
        val scheduledStr: String = message.meta(MqConstants.MQ_META_SCHEDULED)
        if (scheduledStr.isNotEmpty()) {
            scheduled = scheduledStr.toLong()
        }


        //取出所有订阅的主题消息者
        val topicConsumerSet: Set<String>? = subscribeMap[topic]
        if (topicConsumerSet != null) {
            //避免遍历 Set 时，出现 add or remove 而异常
            val topicConsumerList: List<String> = ArrayList(topicConsumerSet)
            for (topicConsumer in topicConsumerList) {
                val topicConsumerQueue = topicConsumerMap[topicConsumer]
                if (topicConsumerQueue != null) {
                    val messageHolder = MqMessageHolder(topicConsumerQueue.consumer, message, tid, qos, scheduled)
                    topicConsumerQueue.add(messageHolder)
                }
            }
        }
    }
}

interface Session{
    fun sessionId():String
    fun attrMap():MutableMap<String,String>
    fun attr(key:String,value: String) = attrMap().put(key, value)
    fun param(key:String):String

    fun send(topic: String, message: Message)
    fun sendAndSubscribe(topic: String, message: Message, block:(Message)->Unit)

    fun close()

    fun replyEnd(m: Message, s: String)
}

interface Message{
    fun meta(prop:String):String

    fun meta(prop: String,value:String)

    fun metaOrDefault(prop: String,value:String):String
    fun isRequest(): Boolean
    fun isSubscribe(): Boolean
}

class MessageImp(val map: MutableMap<String,String> = mutableMapOf()): Message {


    override fun meta(prop: String): String {
      return map[prop]?:""
    }

    override fun meta(prop: String, value: String) {
       map[prop]=value
    }

    override fun metaOrDefault(prop: String, value: String): String {
        return map[prop]?:value
    }

    override fun isRequest(): Boolean {
        TODO("Not yet implemented")
    }

    override fun isSubscribe(): Boolean {
        TODO("Not yet implemented")
    }

}

*//**
 * 消息持有人（为消息添加状态信息）
 *
 * @author noear
 * @since 1.0
 *//*
class MqMessageHolder(
    val consumer: String,
    val from: Message,
    *//**
     * 获取事务Id
     *//*
    //事务Id
    val tid: String,
    *//**
     * 质量等级（0 或 1）
     *//*
    //质量等级（0 或 1）
    val qos: Int,
    *//**
     * 获取派发时间（单位：毫秒）
     *//*
    //派发时间
    var distributeTime: Long
) : Delayed {

    *//**
     * 获取派发次数
     *//*
    //派发次数
    var distributeCount = 0
        private set

    //是否完成
    @get:Synchronized
    @set:Synchronized
    var isDone = false

    *//**
     * 延后（生成下次派发时间）
     *//*
    fun delayed(): MqMessageHolder {
        distributeCount++
        distributeTime = MqNextTime.getNextTime(this)
        return this
    }

    override fun getDelay(unit: TimeUnit): Long {
        return unit.convert(distributeTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS)
    }

    override fun compareTo(o: Delayed): Int {
        val f = distributeTime - (o as MqMessageHolder).distributeTime
        return f.toInt()
    } //不要加 hashCode, equals 重写！
}


*//**
 * 主题消费者队列（服务端给 [一个主题+一个消费者] 安排一个队列，一个消费者可多个会话，只随机给一个会话派发）
 *
 * @author noear
 * @since 1.0
 *//*
interface MqTopicConsumerQueue<Session> {
    *//**
     * 获取主题
     *//*
    val topic: String

    *//**
     * 获取消费者
     *//*
    val consumer: String

    *//**
     * 获取消息表
     *//*
    val messageMap: Map<String, Any>

    *//**
     * 添加消费者会话
     *//*
    fun addSession(session: Session)

    *//**
     * 移除消费者会话
     *//*
    fun removeSession(session: Session)

    *//**
     * 添加消息
     *//*
    fun add(messageHolder: MqMessageHolder)

    *//**
     * 消息数量
     *//*
    fun messageCount(): Int

    *//**
     * 会话数量
     *//*
    fun sessionCount(): Int

    *//**
     * 关闭
     *//*
    fun close()
}

*//**
 * 主题消费者队列默认实现（服务端给 [一个主题+一个消费者] 安排一个队列，一个消费者可多个会话，只随机给一个会话派发）
 *
 * @author noear
 * @since 1.0
 *//*
class MqTopicConsumerQueueDefault<S: Session>(//观察者
    private val watcher: MqWatcher<S>,
    *//**
     * 获取主题
     *//*
    //主题
    override val topic: String,
    *//**
     * 获取消费者
     *//*
    //用户
    override val consumer: String
) : MqTopicConsumerQueue<S> {

    //用户会话（多个）
    private val consumerSessions: MutableList<S>

    //消息字典
    override val messageMap: MutableMap<String, MqMessageHolder>

    //消息队列与处理线程
    private val messageQueue: DelayQueue<MqMessageHolder>
    private val messageQueueThread: Thread?

    init {
        consumerSessions = ArrayList<S>()
        messageMap = ConcurrentHashMap()
        messageQueue = DelayQueue()
        messageQueueThread = Thread { queueTake() }
        messageQueueThread.start()
    }

    private fun queueTake() {
        while (!messageQueueThread!!.isInterrupted) {
            try {
                val messageHolder = messageQueue.take()
                distribute(messageHolder)
            } catch (e: Throwable) {
                *//*if (log.isWarnEnabled()) {
                    log.warn("MqConsumerQueue queueTake error", e)
                }*//*
            }
        }
    }

    *//**
     * 获取消息表
     *//*
     *//*fun getMessageMap(): Map<String, MqMessageHolder> {
        return Collections.unmodifiableMap(messageMap)
    }*//*

    *//**
     * 添加消费者会话
     *//*
    override fun addSession(session: S) {
        consumerSessions.add(session)
    }

    *//**
     * 移除消费者会话
     *//*
    override fun removeSession(session: S) {
        consumerSessions.remove(session)
    }

    *//**
     * 添加消息
     *//*
    override fun add(messageHolder: MqMessageHolder) {
        messageMap[messageHolder.tid] = messageHolder
        messageQueue.add(messageHolder)
    }

    *//**
     * 消息数量
     *//*
    override fun messageCount(): Int {
        return messageQueue.size
    }

    *//**
     * 会话数量
     *//*
    override fun sessionCount(): Int {
        return consumerSessions.size
    }

    *//**
     * 执行派发
     *//*
    protected fun distribute(messageHolder: MqMessageHolder) {
        if (messageHolder.isDone) {
            messageMap.remove(messageHolder.tid)
            return
        }

        //找到此身份的其中一个会话（如果是 ip 就一个；如果是集群名则任选一个）
        if (consumerSessions.size > 0) {
            try {
                distributeDo(messageHolder, consumerSessions)
            } catch (e: Throwable) {
                //进入延后队列
                messageQueue.remove(messageHolder)
                messageQueue.add(messageHolder.delayed())

                //记日志
                *//*if (log.isWarnEnabled()) {
                    log.warn(
                        "MqConsumerQueue distribute error, tid={}",
                        messageHolder.tid, e
                    )
                }*//*
            }
        } else {
            //进入延后队列
            messageQueue.add(messageHolder.delayed())

            //记日志
            *//*if (log.isWarnEnabled()) {
                log.warn(
                    "MqConsumerQueue distribute: no sessions, tid={}",
                    messageHolder.tid
                )
            }*//*
        }
    }

    *//**
     * 派发执行
     *//*
    @Throws(IOException::class)
    private fun distributeDo(messageHolder: MqMessageHolder, sessions: List<S>) {
        //随机取一个会话（集群会有多个会话，实例有时也会有多个会话）
        var idx = 0
        if (sessions.size > 1) {
            idx = Random.nextInt(sessions.size)
        }
        val s1: S = sessions[idx]

        //设置新的派发次数
        messageHolder.from.meta(MqConstants.MQ_META_TIMES, messageHolder.distributeCount.toString())


        //观察者::派发时（在元信息调整之后，再观察）
        watcher.onDistribute(consumer, messageHolder)
        if (messageHolder.qos > 0) {
            //::Qos1

            //添加延时任务：2小时后，如果没有回执就重发（即消息最长不能超过2小时）
            messageHolder.distributeTime = System.currentTimeMillis() + MqNextTime.maxDelayMillis
            messageQueue.add(messageHolder)

            //给会话发送消息 //用 sendAndSubscribe 不安全，时间太久可能断连过（流就不能用了）
            s1.sendAndSubscribe(MqConstants.MQ_EVENT_DISTRIBUTE, messageHolder.from) { m ->
                val ack: Int = m.metaOrDefault(MqConstants.MQ_META_ACK, "0").toInt()
                acknowledgeDo(messageHolder, ack)
            }
        } else {
            //::Qos0
            s1.send(MqConstants.MQ_EVENT_DISTRIBUTE, messageHolder.from)
            //观察者::回执时
            watcher.onAcknowledge(consumer, messageHolder, true)
            messageMap.remove(messageHolder.tid)

            //移除前，不要改移性
            messageHolder.isDone = true
        }
    }

    private fun acknowledgeDo(messageHolder: MqMessageHolder, ack: Int) {
        //观察者::回执时
        watcher.onAcknowledge(consumer, messageHolder, ack > 0)
        if (ack > 0) {
            //ok
            messageMap.remove(messageHolder.tid)
            messageQueue.remove(messageHolder)

            //移除前，不要改移性
            messageHolder.isDone = true
        } else {
            //no （如果在队列改时间即可；如果不在队列说明有补发过）
            messageQueue.remove(messageHolder)
            messageQueue.add(messageHolder.delayed())
        }
    }

    *//**
     * 关闭
     *//*
    override fun close() {
        messageQueueThread?.interrupt()
        messageQueue.clear()
        messageMap.clear()
        consumerSessions.clear()
    }

}

*//**
 * 消息观察者
 *
 * @author noear
 * @since 1.0
 *//*
interface MqWatcher<Session> {
    *//**
     * 初始化
     *//*
    //fun init(serverInternal: MqServiceInternal?)

    *//**
     * 服务启动之前
     *//*
    fun onStartBefore()

    *//**
     * 服务启动之后
     *//*
    fun onStartAfter()

    *//**
     * 服务停止之前
     *//*
    fun onStopBefore()

    *//**
     * 服务停止之后
     *//*
    fun onStopAfter()

    *//**
     * 保存时
     *//*
    fun onSave()

    *//**
     * 订阅时
     *//*
    fun onSubscribe(topic: String, consumer: String, session: Session)

    *//**
     * 取消订阅时
     *//*
    fun onUnSubscribe(topic: String, consumer: String, session: Session)

    *//**
     * 发布时
     *//*
    fun onPublish(message: Message)

    *//**
     * 派发时
     *//*
    fun onDistribute(consumer: String, messageHolder: MqMessageHolder)

    *//**
     * 回执时
     *//*
    fun onAcknowledge(consumer: String, messageHolder: MqMessageHolder, isOk: Boolean)
}

class MqWatcherDefault<Session>: MqWatcher<Session> {
    override fun onStartBefore() {

    }

    override fun onStartAfter() {

    }

    override fun onStopBefore() {

    }

    override fun onStopAfter() {

    }

    override fun onSave() {

    }

    override fun onSubscribe(topic: String, consumer: String, session: Session) {

    }

    override fun onUnSubscribe(topic: String, consumer: String, session: Session) {

    }

    override fun onPublish(message: Message) {

    }

    override fun onDistribute(consumer: String, messageHolder: MqMessageHolder) {

    }

    override fun onAcknowledge(
        consumer: String,
        messageHolder: MqMessageHolder,
        isOk: Boolean
    ) {

    }
}

*//**
 * 派发时间生成器
 *
 * @author noear
 * @since 1.0
 *//*
object MqNextTime {
    *//**
     * 最大延时毫秒数（2小时）
     *//*
    const val maxDelayMillis = (1000 * 60 * 60 * 2).toLong()

    *//**
     * 获取下次派发时间
     *
     * @param messageHolder 消息
     *//*
    fun getNextTime(messageHolder: MqMessageHolder): Long {
        return when (messageHolder.distributeCount) {
            0 -> 0
            1 -> System.currentTimeMillis() + 1000 * 5 //5s
            2 -> System.currentTimeMillis() + 1000 * 30 //30s
            3 -> System.currentTimeMillis() + 1000 * 60 * 3 //3m
            4 -> System.currentTimeMillis() + 1000 * 60 * 9 //9m
            5 -> System.currentTimeMillis() + 1000 * 60 * 15 //15m
            6 -> System.currentTimeMillis() + 1000 * 60 * 30 //30m
            7 -> System.currentTimeMillis() + 1000 * 60 * 60 //60m
            else -> System.currentTimeMillis() + 1000 * 60 * 60 * 2 //120m
        }
    }
}

*//**
 * 常量
 *
 * @author noear
 * @since 1.0
 *//*
interface MqConstants {
    companion object {
        *//**
         * 元信息：消息事务Id
         *//*
        const val MQ_META_TID = "mq.tid"

        *//**
         * 元信息：消息主题
         *//*
        const val MQ_META_TOPIC = "mq.topic"

        *//**
         * 元信息：消息调度时间
         *//*
        const val MQ_META_SCHEDULED = "mq.scheduled"

        *//**
         * 元信息：消息质量等级
         *//*
        const val MQ_META_QOS = "mq.qos"

        *//**
         * 元信息：消息者
         *//*
        const val MQ_META_CONSUMER = "mq.consumer"

        *//**
         * 元信息：派发次数
         *//*
        const val MQ_META_TIMES = "mq.times"

        *//**
         * 元信息：消费回执
         *//*
        const val MQ_META_ACK = "mq.ack"

        *//**
         * 事件：订阅
         *//*
        const val MQ_EVENT_SUBSCRIBE = "mq.event.subscribe"

        *//**
         * 事件：取消订阅
         *//*
        const val MQ_EVENT_UNSUBSCRIBE = "mq.event.unsubscribe"

        *//**
         * 事件：发布
         *//*
        const val MQ_EVENT_PUBLISH = "mq.event.publish"

        *//**
         * 事件：派发
         *//*
        const val MQ_EVENT_DISTRIBUTE = "mq.event.distribute"

        *//**
         * 事件：保存
         *//*
        const val MQ_EVENT_SAVE = "mq.event.save"

        *//**
         * 连接参数：ak
         *//*
        const val PARAM_ACCESS_KEY = "ak"

        *//**
         * 连接参数: sk
         *//*
        const val PARAM_ACCESS_SECRET_KEY = "sk"

        *//**
         * 主题与消息者间隔符
         *//*
        const val SEPARATOR_TOPIC_CONSUMER = "#"

        *//**
         * 经理人服务
         *//*
        const val BROKER_AT_SERVER = "folkmq-server"

        *//**
         * 经理人所有服务
         *//*
        const val BROKER_AT_SERVER_ALL = "folkmq-server*"
    }
}*/
